﻿using System;
using System.Collections.Generic;
using System.Data; 


namespace Orid.Management.Statistics.Tools.Decomposition.Data
{
    class DecompositionOrdersOnline:DecompositionOrders
    {
        public override DataSet GetAllOrders()
        {
            try
            {

                DataSet DSDecompositionOrders;

                string connectString = Config.Setting.SettingInstance.DBAddress_Online;

                string tableName = Config.Setting.SettingInstance.DecompositionOrders_Online;

                DSDecompositionOrders = GetAllOrders(connectString, tableName);

                return DSDecompositionOrders;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw (new Exception(ex.Message));
            }


        }

        /// <summary>
        /// 需要表名：DecompositionOrders
        /// 需要的字段: 受番ID，案件名，受付时间(OrderDateTime),完成时间(FinishDateTime)
        /// FinishTime 完成时间符合条件的
        /// 之前没有处理的受番
        /// </summary>
        /// <param name="starTime"></param>
        /// <param name="finishTime"></param>
        public override DataSet GetDecompositionOrders(DateTimeOffset? starTime, DateTimeOffset? finishTime)
        {
            try
            {
                DataSet DSDecompositionOrders;
                if ((starTime == null) || (finishTime == null))
                {
                    return null;
                }

                string connectString = Config.Setting.SettingInstance.DBAddress_Online;
                string tableName = Config.Setting.SettingInstance.DecompositionOrders_Online;


                DSDecompositionOrders = GetDecompositionOrders(starTime, finishTime, connectString, tableName);

                return DSDecompositionOrders;

            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw (new Exception(ex.Message));
            }


        }

        /// <summary>
        /// Gets the decomposition orders.
        /// </summary>
        /// <param name="orders">The orders.</param>
        /// <returns></returns>
        public override DataSet GetDecompositionOrders(List<Guid> orders)
        {
            try
            {
                DataSet DSDecompositionOrders;
                if ((orders == null) || (orders.Count == 0))
                {
                    return null;
                }

                string connectString = Config.Setting.SettingInstance.DBAddress_Online;
                string tableName = Config.Setting.SettingInstance.DecompositionOrders_Online;


                DSDecompositionOrders = GetDecompositionOrders(orders, connectString, tableName);
                return DSDecompositionOrders;

            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw (new Exception(ex.Message));
            }


        }
    }
}
